export default {
    // 搜索
    seachList(seachchange, page, pagesize) {
        let res = null
        let Searchlistres = []
        let totalList = {
            currentPage: null,
            pageSize: null,
            total: null,
            totalPage: null
        }

        res = window.api.pageDvcAndDvcVer(JSON.stringify(seachchange), page, pagesize)
        // 当前页
        totalList.currentPage = res?.getPageSync()
        // 每页数量
        totalList.pageSize = res?.getPageSizeSync()
        // 总页数
        totalList.totalPage = res?.getTotalPageSync()
        // 总条数
        totalList.total = res?.getTotalSync()

        const size = res?.sizeSync()

        for (let i = 0; i < size; i++) {
            const result = res?.getSync(i)
            const id = result.getSync('id')
            const pid = result.getSync('pid')
            const name = result.getSync('name')
            const channels = result.getSync('channels')
            const DevicetypeName = result.getSync('DevicetypeName')
            const DevicetypeValue = result.getSync('DevicetypeValue')
            const isShow = result.getSync('isShow')
            const amplitude = result.getSync('amplitude')
            const delay = result.getSync('delay')
            const isVirtual = result.getSync('isVirtual')
            const ComPort = result.getSync('ComPort') ? result.getSync('ComPort') : undefined
            const BaudRate = result.getSync('BaudRate') ? result.getSync('BaudRate') : undefined
            const isDelete = result.getSync('isDelete')
            const property = result.getSync('property')
            const dynamicTags = result.getSync('dynamicTags')
            const SystemVariableType = result.getSync('SystemVariableType')
            const Expression = result.getSync('Expression')

            let list = {
                id: id,
                pid: pid,
                name: name,
                DevicetypeName: DevicetypeName,
                DevicetypeValue: DevicetypeValue,
                Channels: channels,
                isShow: isShow,
                amplitude: amplitude,
                delay: delay,
                isVirtual: isVirtual,
                ComPort: ComPort,
                BaudRate: BaudRate,
                isDelete: isDelete,
                property: property,
                dynamicTags: dynamicTags,
                SystemVariableType: SystemVariableType,
                Expression: Expression
            }
            Searchlistres.push(list)
        }
        return { totalList, Searchlistres }
    }
}